home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / em-xmkit.zip / EMM04_A.ASM < prev    next >
Assembly Source File  |  1989-11-29  |  6KB  |  109 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM04_A.ASM                                             ;
  3. ;                                                                             ;
  4. ;    FUNCTION NAME:   alloc_pages                                             ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function allocates the number of pages requested   ;
  7. ;                     and assigns a unique EMM handle to these pages.  The    ;
  8. ;                     EMM handle owns these pages until the application       ;
  9. ;                     deallocates them.                                       ;
  10. ;                                                                             ;
  11. ;                     Handles which are assigned using this function will     ;
  12. ;                     have 16K-byte pages, the size of a standard expanded    ;
  13. ;                     memory page.  If the expanded memory board hardware     ;
  14. ;                     isn't able to supply 16K-byte pages, it will emulate    ;
  15. ;                     them by combining multiple non-standard size pages to   ;
  16. ;                     form a single 16K-byte page.  All application programs  ;
  17. ;                     and functions that use the handles this function        ;
  18. ;                     returns will deal with 16K-byte pages.                  ;
  19. ;                                                                             ;
  20. ;                     The numeric values of the handles the EMM returns are in;
  21. ;                     the range of 1 to 254 decimal.  The OS handle (handle   ;
  22. ;                     value 0) is never returned by the alloc_pages function. ;
  23. ;                     A memory manager should be able to supply up to 255     ;
  24. ;                     handles, including the OS handle.  An application can   ;
  25. ;                     use the get_total_handles function to find out how many ;
  26. ;                     handles an EMM supports.                                ;
  27. ;                                                                             ;
  28. ;                     You can't allocate zero pages to a handle with the      ;
  29. ;                     alloc_pages function.  If your application needs to     ;
  30. ;                     allocate zero pages to a handle, use the                ;
  31. ;                     alloc_std_pages function provided for this purpose.     ;
  32. ;                                                                             ;
  33. ;           PASSED:   pages:                                                  ;
  34. ;                        is the number of pages you want your program to      ;
  35. ;                        allocate.                                            ;
  36. ;                                                                             ;
  37. ;                     &handle:                                                ;
  38. ;                        is a far pointer to a unique EMM handle.             ;
  39. ;                                                                             ;
  40. ;         RETURNED:   status:                                                 ;
  41. ;                        is the status EMM returns from the call.  All other  ;
  42. ;                        returned results are valid only if the status        ;
  43. ;                        returned is zero.  Otherwise they are undefined.     ;
  44. ;                                                                             ;
  45. ;                     handle:                                                 ;
  46. ;                        is a unique EMM handle.  Your program must use this  ;
  47. ;                        EMM handle (as a parameter) in any function that     ;
  48. ;                        requires it.  You can use up to 255 handles.         ;
  49. ;                                                                             ;
  50. ; C USE CONVENTION:   unsigned int status;                                    ;
  51. ;                     unsigned int pages;                                     ;
  52. ;                     unsigned int handle;                                    ;
  53. ;                                                                             ;
  54. ;                     status = alloc_pages (pages,                            ;
  55. ;                                           &handle);                         ;
  56. ;-----------------------------------------------------------------------------;
  57. .XLIST
  58. PAGE    60,132
  59.  
  60. IFDEF SMALL
  61.    .MODEL SMALL, C
  62. ENDIF
  63. IFDEF MEDIUM
  64.    .MODEL MEDIUM, C
  65. ENDIF
  66. IFDEF LARGE
  67.    .MODEL LARGE, C
  68. ENDIF
  69. IFDEF COMPACT
  70.    .MODEL COMPACT, C
  71. ENDIF
  72. IFDEF HUGE
  73.    .MODEL HUGE, C
  74. ENDIF
  75.  
  76. INCLUDE emmlib.equ
  77. INCLUDE emmlib.str
  78. INCLUDE emmlib.mac
  79. .LIST
  80. .CODE
  81.  
  82. alloc_pages        PROC                                                  \
  83.             pages:WORD,                                           \
  84.             ptr_handle:FAR PTR WORD
  85.  
  86.     ;---------------------------------------------------------------------;
  87.     ;   do;                                                               ;
  88.     ;   .   allocate the number of pages requested from EMM;              ;
  89.     ;---------------------------------------------------------------------;
  90.     MOVE        AH, allocate_pages_fcn
  91.     MOVE        BX, pages
  92.     INT         EMM_int
  93.  
  94.     ;---------------------------------------------------------------------;
  95.     ;   .   pass the EMM handle back to the caller;                       ;
  96.     ;---------------------------------------------------------------------;
  97.     MOVE        ES:BX, ptr_handle
  98.     MOVE        ES:[BX], DX
  99.  
  100.     ;---------------------------------------------------------------------;
  101.     ;   .   return (EMM status);                                          ;
  102.     ;   end;                                                              ;
  103.     ;---------------------------------------------------------------------;
  104.     RET_EMM_STAT    AH
  105.  
  106. alloc_pages        ENDP
  107.  
  108. END
  109.